﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GUI_Client_WCF
{
    public partial class ShowBookingDetails : Form
    {
        private static ShowBookingDetails instance;
        private ServiceReference.Booking booking;
        private ServiceReference.IService reference;
        
        private ShowBookingDetails()
        {
            booking = GUIBookings.Booking;
            reference = new ServiceReference.ServiceClient();

            InitializeComponent();

            var items = reference.GetBookingItemsFromBooking(booking.bookingID);
            int count = 0;
            foreach (var item in items)
            {
                count++;
                ServiceReference.BatteryItem bi = reference.GetBatteryItem(item.batteryID);
                ServiceReference.BatteryStation bs = reference.GetBatteryStationByID(bi.stationID);
                dataGridView.Rows.Add(count, bs.name);
            }
        }

        public static ShowBookingDetails Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ShowBookingDetails();
                }
                return instance;
            }
        }

        private void backBtn_Click(object sender, EventArgs e)
        {
            GUIBookings bookings = GUIBookings.Instance;
            bookings.Show();

            this.Hide();
        }
    }
}
